import heapq
for _ in range(int(input())):
n,m,x = map(int,input().split())
h = list(map(int,input().split()))
tower = [[0,i] for i in range(m)]
heapq.heapify(tower)
res = [0]*n
for j in range(n):
height, idx = heapq.heappop(tower)
height += h[j]
res[j] = idx+1
heapq.heappush(tower,[height,idx])
if abs(tower[0][0]-tower[-1][0])<=x:
print("YES")
print(*res)
else:
print("NO")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,n) for(ll i=1;i<=n;i++)
const ll M=1e9+7;
const ll N=1e6+1;
ll dp[N];
void solve(){
ll n,m,x;
cin>>n>>m>>x;
vector<ll> h(n+1);
loop(i,n) cin>>h[i];
set<pair<ll,ll>> ht;
for(ll i=1;i<=m;i++){
ht.insert(make_pair(0,i));
}
cout<<"YES"<<endl;
for(ll i=1;i<=n;i++){
auto it=*(ht.begin());
ht.erase(it);
cout<<it.second<<" ";
ht.insert(make_pair(it.first+h[i],it.second));
}
cout<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin>>t;
while(t--){
solve();
}
return 0;
}
262A - Roma and Lucky Numbers | 1634B - Fortune Telling |
1358A - Park Lighting | 253C - Text Editor |
365B - The Fibonacci Segment | 75A - Life Without Zeros |
1519A - Red and Blue Beans | 466A - Cheap Travel |
659E - New Reform | 1385B - Restore the Permutation by Merger |
706A - Beru-taxi | 686A - Free Ice Cream |
1358D - The Best Vacation | 1620B - Triangles on a Rectangle |
999C - Alphabetic Removals | 1634C - OKEA |
1368C - Even Picture | 1505F - Math |
1473A - Replacing Elements | 959A - Mahmoud and Ehab and the even-odd game |
78B - Easter Eggs | 1455B - Jumps |
1225C - p-binary | 1525D - Armchairs |
1257A - Two Rival Students | 1415A - Prison Break |
1271A - Suits | 259B - Little Elephant and Magic Square |
1389A - LCM Problem | 778A - String Game |